UART I2C SPI 2 Click
UART I2C SPI 2 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Filipovic
- Date : Sep 2025.
- Type : I2C/SPI type
Software Support
Example Description
This example demonstrates the use of the UART I2C SPI 2 Click board. It sends a predefined demo message to both UART0 and UART1 interfaces, then reads back any received data and logs the results on the USB UART.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.UARTI2CSPI2
Example Key Functions
- uarti2cspi2_cfg_setup This function initializes Click configuration structure to initial values.
void uarti2cspi2_cfg_setup(uarti2cspi2_cfg_t *cfg)
UART I2C SPI 2 configuration object setup function.
UART I2C SPI 2 Click configuration object.
Definition uarti2cspi2.h:434
- uarti2cspi2_init This function initializes all necessary pins and peripherals used for this Click board.
err_t uarti2cspi2_init(uarti2cspi2_t *ctx, uarti2cspi2_cfg_t *cfg)
UART I2C SPI 2 initialization function.
struct uarti2cspi2_s uarti2cspi2_t
UART I2C SPI 2 Click context object.
- uarti2cspi2_default_cfg This function executes a default configuration of UART I2C SPI 2 Click board.
err_t uarti2cspi2_default_cfg(uarti2cspi2_t *ctx)
UART I2C SPI 2 default configuration function.
- uarti2cspi2_read_reg This function reads a single byte of data from the selected register address.
err_t uarti2cspi2_read_reg(uarti2cspi2_t *ctx, uint8_t reg, uint8_t *data_out)
UART I2C SPI 2 read register function.
- uarti2cspi2_read_data This function reads a block of data from the receive buffer.
err_t uarti2cspi2_read_data(uarti2cspi2_t *ctx, uint8_t *data_out, uint8_t len)
UART I2C SPI 2 read data function.
- uarti2cspi2_write_data This function writes a block of data to the transmit buffer.
err_t uarti2cspi2_write_data(uarti2cspi2_t *ctx, uint8_t *data_in, uint8_t len)
UART I2C SPI 2 write data function.
Application Init
Initializes the logger and UART I2C SPI 2 Click, and applies the default configuration which sets the UART0 to 115200-8N1 and UART1 to 9600-8N1.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( ( I2C_MASTER_ERROR == init_flag ) || ( SPI_MASTER_ERROR == init_flag ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define UARTI2CSPI2_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition uarti2cspi2.h:374
void application_init(void)
Definition main.c:38
@ UARTI2CSPI2_ERROR
Definition uarti2cspi2.h:462
Application Task
Alternately selects UART0 and UART1, sends the demo message, reads back data from the RX FIFO, and logs the transmitted and received strings every second.
{
uint8_t fifo_lvl = 0;
{
{
}
}
{
{
log_printf ( &logger, "Read from U0: %s\r\n", fifo_data );
}
}
{
{
}
}
{
{
log_printf ( &logger, "Read from U1: %s\r\n", fifo_data );
}
}
Delay_ms ( 1000 );
}
#define UARTI2CSPI2_REG_RXFIFOLVL
Definition uarti2cspi2.h:94
#define UARTI2CSPI2_FIFO_LEN
Definition uarti2cspi2.h:335
void uarti2cspi2_select_uart_1(uarti2cspi2_t *ctx)
UART I2C SPI 2 select UART 1 function.
void uarti2cspi2_select_uart_0(uarti2cspi2_t *ctx)
UART I2C SPI 2 select UART 0 function.
void application_task(void)
Definition main.c:75
#define DEMO_MESSAGE
Definition main.c:33
@ UARTI2CSPI2_OK
Definition uarti2cspi2.h:461
Note
Ensure that the connected devices on UART0 and UART1 are properly configured to communicate at the same baud rate and parameters.
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.